<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<jsp:useBean id="bean" class="com.lmpop.frame.util.RandomID" scope="page"/>
<%@page import="com.lmpop.trade.ti_address.*" %>
<%@page import="com.lmpop.trade.ts_area.*" %>
  <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
  <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
  <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
  <script type="text/javascript" src="/program/member/address/js_area.js"></script>
  <script type="text/javascript" src="/program/member/address/index.js"></script>
<%
		String pri_key = bean.GenTradeId();
		String cust_id="",publish_user_id="";
		if(session.getAttribute("session_cust_id")!=null){
			cust_id  = session.getAttribute("session_cust_id").toString();
		}
		if(session.getAttribute("session_user_id")!=null){
			publish_user_id  = session.getAttribute("session_user_id").toString();
		}

	    Ti_addressInfo ti_addressInfo = new Ti_addressInfo();
		Map map=ti_addressInfo.getOneAddrByLevel(publish_user_id);
		String consignee="",addr_id="",level_no="0",email="",area_attr="",address="",post_code="",tel="",cellphone="",best_time="",in_date="",remark="";
		String areaAttr = "";	
		if(map!=null){
			if(map.get("addr_id")!=null) addr_id = map.get("addr_id").toString();
		  	if(map.get("consignee")!=null) consignee = map.get("consignee").toString();
		  	if(map.get("level_no")!=null) level_no = map.get("level_no").toString();
		  	if(level_no.equals("")||level_no==null)level_no="0";
		  	if(map.get("email")!=null) email = map.get("email").toString();
		  	if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
		  	if(map.get("address")!=null) address = map.get("address").toString();
		  	if(map.get("post_code")!=null) post_code = map.get("post_code").toString();
		  	if(map.get("tel")!=null) tel = map.get("tel").toString();
		  	if(map.get("cellphone")!=null) cellphone = map.get("cellphone").toString();
		  	if(map.get("best_time")!=null) best_time = map.get("best_time").toString();
		  	if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
		  	if(map.get("remark")!=null) remark = map.get("remark").toString();
			Ts_areaInfo areaBean = new Ts_areaInfo(); 			
			if (map.get("area_attr") != null) {
				area_attr = map.get("area_attr").toString();
				String areaArr[] = area_attr.split("\\|");
				for( int k = 0; k < areaArr.length; k++ ){
					areaAttr = areaAttr + "" + areaBean.getAreaNameById( areaArr[k]);
				}
			}	
		}
	if(areaAttr.equals(""))
		areaAttr="请选择地区";
%>

<form action="/doTradeReg.do" method="post" name="addaddressForm">
	
	<input name="cust_id" id="cust_id" type="hidden" value="<%=cust_id%>"/>
    <input name="_addr_id" id="_addr_id" value="<%=pri_key%>" type="hidden" />
     <input name="addr_id" id="addr_id" value="<%=addr_id%>" type="hidden" />
	<input name="user_id" id="user_id" value="<%=publish_user_id%>" type="hidden" />
	<input name="a" id="addr_id" value="<%=publish_user_id%>" type="hidden" />
				 <div class="f-input"><span><strong>*</strong>邮箱:</span>
                   <input name="email" id="email"  type="text" value="<%=email %>"  class="field"/>
                  </div>
                  <div class="f-input"><span><strong>*</strong>收货人姓名:</span>
                    <input name="consignee" id="consignee" value="<%=consignee %>" type="text"  class="field"/>
                  </div>
                    <div class="f-input"><span><strong>*</strong>电话:</span>
                   <input name="tel" id="tel" type="text" value="<%=cellphone %>"  class="field"/>
                  </div>
                  <div class="f-input"><span><strong>*</strong>手机:</span>
                   <input name="cellphone" id="cellphone" onKeyUp="if(!/^[0-9][0-9]*$/.test(this.value))this.value=''" type="text" value="<%=cellphone %>"  class="field"/>
                  </div>
                  <div class="f-input"><span><strong>*</strong>邮编:</span>
                   <input name="post_code" id="post_code" onKeyUp="if(!/^[0-9][0-9]*$/.test(this.value))this.value=''"  type="text" value="<%=email %>"  class="field"/>
                  </div>
                  	<div id="org1" class="f-input"><span><strong>*</strong>所在地区:</span>　
						<font color="#CECECE"><%=areaAttr%></font>
						<button type="button" name="buttons" value="修改" class="gdbtn" onClick="ChangeOrg()" >修改</button> 
					</div>
					<div style="display:none;" id="org2" class="f-input"><span><strong>*</strong>所在地区:</span>　 
						<select name="province" id="province" onclick="setCitys(this.value)">
						  <option value="">省份</option> 
						</select>
						<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
						  <option value="">城市</option> 
						 </select>
						<select name="city_code" id="city_code" style="display:inline" >
						 <option value="">地区</option> 
						</select>
					</div> 
                  <div class="f-input"><span style=" margin-top:20px; float:left"><strong>*</strong>配送地址:</span>
                    <textarea name="address"  id="address"  class="field_textarea"><%=address %></textarea>
                  </div>
                  <div class="f-input">
                    <center>
                    <input name="level_no" id="level_no" type="hidden" value="0"/>
                     <input name="area_attr" id="area_attr" type="hidden" value="<%=area_attr %>"/>
					<input type="hidden" name="bpm_id" id="bpm_id" value="2575" />
					<input type="hidden" name="jumpurl" value="/8diantuan_member.html" />
					<button type="button" class="gdbtn" name="tradeSub" value="提交" onclick="return checkSub();">提交</button>&nbsp;&nbsp;
                    </center>
                  </div>
</form>
